package com.tally.project.system.billing.controller;

import com.tally.framework.web.AjaxResult;
import com.tally.framework.web.controller.BaseController;
import com.tally.framework.web.page.TableDataInfo;
import com.tally.project.system.billing.domain.Billing;
import com.tally.project.system.billing.service.IBillingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 账目流水信息Controller
 * @author soul
 * @date 2023-05-14
 */
@Api(tags = "账目流水信息")
@Controller
@RequestMapping("/system/billing")
public class BillingController extends BaseController
{
    @Resource
    private IBillingService billingService;

    /**
     * 查询账目流水信息列表
     */
    @ApiOperation("账目流水信息列表")
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult list(@RequestBody Billing billing)
    {
        return AjaxResult.success(billingService.selectBillingList(billing));
    }

    /**
     * 新增账目流水信息
     */
    @ApiOperation("新增账目流水信息")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody Billing billing)
    {
        return toAjax(billingService.insertBilling(billing));
    }

    /**
     * 修改账目流水信息
     */
    @ApiOperation("修改账目流水信息")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody Billing billing)
    {
        return toAjax(billingService.updateBilling(billing));
    }

    /**
     * 删除账目流水信息
     */
    @ApiOperation("删除账目流水信息")
    @DeleteMapping( "/remove/{ids}")
    @ResponseBody
    public AjaxResult remove(@PathVariable("ids") String ids)
    {
        return toAjax(billingService.deleteBillingByIds(ids));
    }

    /**
     * 账目流水信息
     */
    @ApiOperation("账目流水详情")
    @GetMapping("/detail/{id}")
    @ResponseBody
    public AjaxResult detail(@PathVariable("id") Long id)
    {
        return AjaxResult.success(billingService.selectBillingById(id));
    }

    /**
     * 账目流水统计
     */
    @ApiOperation("账目流水统计")
    @PostMapping("/statistic")
    @ResponseBody
    public TableDataInfo statistic(@RequestBody Billing billing)
    {
        return getDataTable(billingService.selectBillingStatisticList(billing));
    }

}
